﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using DAL.SQLStatements;
using DigitalAnts.App_Code.BAL.Entities;
using BAL.Utils;

namespace DigitalAnts.App_Code.DAL.LogicComponents
{
    public class clsFeedbackDAL
    {
        #region --- Get All Feedback
        public static DataTable doFeedbackSelectList()
        {
            // Select all of products by user id
            clsQueryBuilder query = new clsQueryBuilder();
            query.propTable = "tblFeedback";
            query.propColumn = "*";
            query.propWhere = "colStatus = 1";

            // return result
            return query.getDatatable();
        }
        #endregion ---

        #region --- Get Feedback by id
        public static DataTable doFeedbackSelectListById(clsFeedback obj)
        {
            // Select all of products by user id
            clsQueryBuilder query = new clsQueryBuilder();
            query.propTable = "tblFeedback";
            query.propColumn = "*";
            query.propWhere = "colFeedbackID = '" + obj.FeedbackID + "' and colStatus = 1";

            // return result
            return query.getDatatable();
        }
        #endregion ---

        #region --- Add new Feedback
        public static bool doAddNewFeedback(clsFeedback obj)
        {
            clsQueryBuilder query = new clsQueryBuilder();
            
            Dictionary<String, Object> data = new Dictionary<String,Object>();
            data.Add("colFullName", "N'" + obj.Fullname + "'");
            data.Add("colEmail", "'" + obj.Email + "'");
            data.Add("colPhone", obj.Phone);
            data.Add("colTitle", "N'" + obj.Detail + "'");
            data.Add("colContent", "N'" + obj.Content + "'");
            data.Add("colInsertDate", "'" + clsDateTimeSetting.UTCTime() + "'");
            data.Add("colStatus", 1);
            data.Add("colIsReaded", 1);
            // return result
            return query.executeInsertInto("tblFeedback", data);
        }
        #endregion ---
    }
}